require 'action_controller/metal/renderers'
require 'action_controller/metal/responder'
require 'action_dispatch/http/mime_type'

# this will let us do thing like 'render :key => :key_to_partial' in views
#TODO need to extend the ActionView::Renderer.new.render method not rewrite
module ActionView
  class Renderer
    def render context, options
      if options[:key]
        if attribute = Rpbk.find_with_context(options[:key], context)
          options[:partial] = attribute.value
        else
          options[:text] = "Partial #{options[:key].inspect} not found!" 
        end
        options.delete(:key)
      end
      # copy from : /actionpack-3.1.0/lib/action_view/renderer/renderer.rb function render(context, options)
      if options.key?(:partial)
        render_partial(context, options)
      else
        render_template(context, options)
      end
    end
  end
end
